// ============================================================================
//
// Copyright (C) 2006-2007 Dengues
//
// Google Group: http://groups.google.com/group/dengues
// QQ Group: 24885404
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
// ============================================================================
package org.dengues.designer.ui.process.models;

import org.dengues.core.process.CompElement;
import org.dengues.core.process.ICompProcess;
import org.eclipse.draw2d.geometry.Dimension;
import org.eclipse.draw2d.geometry.Point;

/**
 * Qiang.Zhang.Adolf@gmail.com class global comment. Detailled comment <br/>
 * 
 * @since 2007-10-14 下午08:38:40
 */
public class CompNodeStatus extends CompElement {

    private final CompNode node;

    public static String PROP_CHANGE = "CompNodeStatus.Change"; //$NON-NLS-1$

    private String message;

    private Point location = new Point(0, 0);

    public static final int STATUS_NORMAL = 0;

    public static final int STATUS_INFO = 10;

    public static final int STATUS_WARNING = 20;

    public static final int STATUS_ERROR = 30;

    private int type = STATUS_NORMAL;

    /**
     * 
     */
    private static final long serialVersionUID = 123234455456487L;

    /**
     * Qiang.Zhang.Adolf@gmail.com CompNodeStatus constructor comment.
     */
    public CompNodeStatus(CompNode node) {
        this.node = node;
    }

    /*
     * (non-Javadoc)
     * 
     * @see org.dengues.designer.ui.process.models.CompElement#getCompName()
     */
    @Override
    public String getCompName() {
        return node.getUniqueName() + "'s Status"; //$NON-NLS-1$
    }

    /*
     * (non-Javadoc)
     * 
     * @see org.dengues.designer.ui.process.models.CompElement#getCompProcess()
     */
    @Override
    public ICompProcess getCompProcess() {
        return node.getCompProcess();
    }

    public void setLocation(Point location) {
        this.location = location;
        fireStructureChange(PROP_CHANGE, this.location);
    }

    /*
     * (non-Javadoc)
     * 
     * @see org.dengues.core.process.ICompElement#getLocation()
     */
    @Override
    public Point getLocation() {
        return this.location;
    }

    /*
     * (non-Javadoc)
     * 
     * @see org.dengues.core.process.ICompElement#getSize()
     */
    @Override
    public Dimension getSize() {
        return null;
    }

    /**
     * Getter for message.
     * 
     * @return the message
     */
    public String getMessage() {
        return this.message;
    }

    /**
     * Sets the message.
     * 
     * @param message the message to set
     */
    public void setMessage(String message) {
        this.message = message;
        fireStructureChange(PROP_CHANGE, message);
    }

    /**
     * Getter for type.
     * 
     * @return the type
     */
    public int getType() {
        return this.type;
    }

    /**
     * Sets the type.
     * 
     * @param type the type to set
     */
    public void setType(int type) {
        this.type = type;
        fireStructureChange(PROP_CHANGE, type);
    }

}
